program e;

{$APPTYPE CONSOLE}

var
  c, i, n, m, mi, mc: Integer;
  ms: char;
  rs: String;
  equals: Boolean;
  a, b: array[1..1000000] of Integer;
function i2s(i: Integer): String;
begin
  Str(i, Result);
end;

begin
  readln(n, m);
  FillChar(a, 0, m);
  ms := '+';
  equals := False;
  rs := '';
  read(c);
  Inc(a[c]);
  mi := c;
  mc := 1;
  b[1] := c;
  for i := 2 to n do
  begin
    read(c);
    Inc(a[c]);
    equals := a[c] = mc;
    if equals then
      b[i] := -1
    else begin
      if a[c] > mc then begin
        mi := c;
        mc := a[c]
      end;
      b[i] := mi;
    end;
  end;
  write(b[1]);
  for i := 2 to n do
    if b[i] = -1 then
      write(' +')
    else
      write(' ', b[i]);
  writeln;
end.
